#include <bits/stdc++.h>

using namespace std;

char a[100],b[100];
int len,cnt,lt;
string x,y,t;
int main()
{
    memset(a,'*',sizeof(a));
    memset(b,'*',sizeof(b));
    cin>>x>>y>>t;
    lt = t.length();
    len = x.length();
    for(int i=0;i<len;i++){
        if(a[x[i]]=='*'&&b[y[i]]=='*'){
            a[x[i]]=y[i];
            b[y[i]]=x[i];
            cnt++;
        }
        else if(a[x[i]]!=y[i]||b[y[i]]!=x[i]){
            cout<<"Failed";
            return 0;
        }
    }
    if(cnt<26){
        cout<<"Failed";
        return 0;
    }
    for(int i = 0;i<lt;i++){
        cout<<a[t[i]];
    }
    return 0;
}
